﻿<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Register TagPrefix="wssuc" TagName="InputFormSection" src="~/_controltemplates/InputFormSection.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="InputFormControl" src="~/_controltemplates/InputFormControl.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="ButtonSection" src="~/_controltemplates/ButtonSection.ascx" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="StyleWeb.aspx.cs" Inherits="CP.SharePoint.SiteStyles.Layouts.StyleWeb" DynamicMasterPageFile="~masterurl/default.master" %>

<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
 
<script type="text/javascript">
    function previewSiteStyle() {
        var listBox = document.getElementById(stylesListBoxId);
        var img = document.getElementById('sitestyle-previewImage');
        var desc = document.getElementById('sitestyle-description');

        var styleItem = availableStyles[listBox.selectedIndex];

        if (styleItem.ThumbnailPath == '') {
            img.src = '/_layouts/images/cp.sharepoint.sitestyles/defaultsitestyle.png';
        }
        else {
            img.src = styleItem.ThumbnailPath;
        }
        desc.innerHTML = styleItem.Description;
    }

    function _spBodyOnLoad() {
        var listBox = document.getElementById(stylesListBoxId);
        addEvent(listBox, "change", previewSiteStyle, false);
        previewSiteStyle();
    }

    function addEvent(obj, evType, fn, useCapture) {
        if (obj.addEventListener) {
            obj.addEventListener(evType, fn, useCapture);
            return true;
        } else if (obj.attachEvent) {
            var r = obj.attachEvent("on" + evType, fn);
            return r;
        } else {
            alert("Handler could not be attached");
        }
    }

    function styleItem(description, thumbnail) {
        this.Description = description;
        this.ThumbnailPath = thumbnail;
    }
</script>

<style type="text/css">
    .sitestyle-table { width: 100%; }
    .sitestyle-previewpane { text-align: center; }
    .sitestyle-preview { font-weight: bold; }    
</style>

</asp:Content>

<asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
Site Style
</asp:Content>

<asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server" >
<a href="../settings.aspx"><SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,settings_pagetitle%>" EncodeMethod="HtmlEncode"/></a>&#32;<SharePoint:ClusteredDirectionalSeparatorArrow runat="server" /> Site Style
</asp:Content>

<asp:Content ContentPlaceHolderId="PlaceHolderPageDescription" runat="server">
Use this page to change the style for your site. You can select a style or you can configure new site styles within Central Administration. Applying a site style does not affect your site's layout.
</asp:Content>

<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">

<table border="0" cellpadding="0" cellspacing="0" class="sitestyle-table">
    <wssuc:InputFormSection runat="server">
		<Template_Title>
            Inherit Site Style
		</Template_Title>
		<Template_Description>
            Specify whether this site uses the same site style as its parent or if it uses its own site style.
		</Template_Description>
		<Template_InputFormControls>
			<wssuc:InputFormControl runat="server"  LabelText="" LabelAssociatedControlId="">
			    <Template_Control>
                     <asp:RadioButtonList ID="inheritanceRadioButtonList" runat="server" AutoPostBack="true">
                        <asp:ListItem Text="Inherit site style from the parent of this site" Value="0" Selected="True" />
                        <asp:ListItem Text="Specify a site style to be used by this site and all sites that inherit from it" Value="1" />
                     </asp:RadioButtonList>               
			    </Template_Control>
			</wssuc:InputFormControl>
		</Template_InputFormControls>
	</wssuc:InputFormSection>

    <wssuc:InputFormSection runat="server">
		<Template_Title>
            Select a Site Style
		</Template_Title>
        
		<Template_Description>
            <div class="sitestyle-previewpane">
                <p>
                    <img id="sitestyle-previewImage" alt="" src="/_layouts/images/cp.sharepoint.sitestyles/defaultsitestyle.png"/>
                </p>
			    <p class="sitestyle-preview">Preview</p>
                <p id="sitestyle-description"></p>
            </div>
		</Template_Description>
		<Template_InputFormControls>
			<wssuc:InputFormControl runat="server"  LabelText="" LabelAssociatedControlId="">
			    <Template_Control>
                     <asp:ListBox Width="90%" Height="300px" ID="availableStylesListBox" runat="server"></asp:ListBox>             
			    </Template_Control>
			</wssuc:InputFormControl>
		</Template_InputFormControls>
	</wssuc:InputFormSection>

    <wssuc:InputFormSection runat="server">
		<Template_Title>
            Apply Site Style
		</Template_Title>
		<Template_Description>
            Specify whether to apply the selected site style to this site only or to all its subsites. Applying this site style to all subsites will override any individual site style settings on those sites. 
		</Template_Description>
		<Template_InputFormControls>
			<wssuc:InputFormControl runat="server"  LabelText="" LabelAssociatedControlId="">
			<Template_Control>
                 <asp:RadioButtonList ID="applyToRadioButtonList" runat="server">
                    <asp:ListItem Text="Apply the selected site style to this site only" Value="0" Selected="True"/>
                    <asp:ListItem Text="Apply the selected site style to this site and reset all subsites to inherit this setting" Value="1" />
                 </asp:RadioButtonList>               
			</Template_Control>
			</wssuc:InputFormControl>
		</Template_InputFormControls>
	</wssuc:InputFormSection>
	
</table>

<table border="0" cellspacing="0" cellpadding="0" class="ms-propertysheet" width="100%">
	<wssuc:ButtonSection runat="server">
		<Template_Buttons>
			<asp:Button UseSubmitBehavior="false" runat="server" class="ms-ButtonHeightWidth" Text="Apply Style" id="applyStyleButton"/>
		</Template_Buttons>
	</wssuc:ButtonSection>
</table>

</asp:Content>


